﻿
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Net.PeerToPeer;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
using LightLog.IService;
using LightLog.Model.Input;
using LightLog.Model.Output;
using LightLogApi.Code.Attributes;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;

namespace LightLogApi.Controllers
{
    public class LogController : BaseController
    {
        private readonly ILogInfoService _ilogInfoService;

        public LogController(ILogInfoService ilogInfoService)
        {
            _ilogInfoService = ilogInfoService;
        }


        /// <summary>
        /// 发送日志
        /// </summary>
        /// <param name="inputList">日志信息实体集合</param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IResponseOutput> RecodeAsync([FromBody] List<SeriLogInput> inputList)
        {
            bool result = true;
            foreach (var input in inputList)
            {
                if (!await _ilogInfoService.LoggingAsync(input))
                    result = false;
            }

            return result ? ResponseOutput.Ok() : ResponseOutput.NotOk();
        }

    }
}
